home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / msdos / mcpr / cpropt.asm < prev    next >
Assembly Source File  |  1991-10-18  |  16KB  |  885 lines

  1.     page    95,132
  2. ;§∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞§
  3. ;§                                                                          §
  4. ;§            マルチカラム コンパクト プリント ユーティリティ            §
  5. ;§                                                                          §
  6. ;§   Multicolumn Compact PRint utility   MCPR.EXE  Ver1.40    §
  7. ;§   ~           ~       ~~                                                 §
  8. ;§              Copyright (C) by 福地 邦雄 1989-1990. All rights reserved.  §
  9. ;§∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞§
  10.     public    options
  11.     public    startpage
  12.     public    lastpage
  13.     public    clmcnt
  14.     public    lincnt
  15.     public    blkcnt
  16.     public    gapsize
  17.     public    formfeed
  18.     public    creturns
  19.     public    marginleft
  20.     public    marginhead
  21.     public    hdrprint
  22.     public    header
  23.     public    headeroff
  24.     public    headerseg
  25.     public    pgwidth
  26.     public    pghight
  27.     public    rawpitch
  28.     public    clmpitch
  29.     public    pprtype
  30.     public    frmtype
  31.     public    hopper
  32.     public    pgtype
  33.     public    filline
  34.     public    linsiz
  35.     public    linumb
  36.     public    numclm
  37.     public    numsepchar
  38.     public    tabcount
  39.     extrn    asctoint:near
  40.     extrn    inttoascb:near
  41.     extrn    filelist:near
  42.     extrn    abort:near
  43.     extrn    asmpage:near
  44.     extrn    baspage:near
  45.     extrn    cpage:near
  46. ;
  47. YES    equ    1
  48. NO    equ    0
  49. EXT    equ    1
  50. ASM    equ    2
  51. BASIC    equ    3
  52. C    equ    4
  53. CR    equ    0dh
  54. LF    equ    0ah
  55. PORT    equ    0
  56. LAND    equ    1
  57. STOCK136 equ    0
  58. STOCK80 equ    1
  59. A4    equ    2
  60. B4    equ    3
  61. ;
  62. findf    struc
  63. ;    namstr    label    dword
  64.     namoff    dw    ?
  65.     namseg    dw    ?
  66. ;    dtaadr    label    dword
  67.     dtaoff    dw    ?
  68.     dtaseg    dw    ?
  69. ;    bufadr    label    dword
  70.     bufoff    dw    ?
  71.     bufseg    dw    ?
  72.     bufsiz    dw    ?
  73. findf    ends
  74. ;
  75. pgform    struc
  76.     allwidth    dw    ?
  77.     leftmrgn    dw    ?
  78.     blckclmn    dw    ?
  79.     gapclmn        dw    ?
  80.     blckcount    dw    ?
  81.     physline    dw    ?
  82.     prntline    dw    ?
  83.     headmrgn    dw    ?
  84. pgform    ends
  85. ;
  86. data    segment para    public    'DATA'
  87. ;
  88. extrn    namebuf:dword
  89. extrn    nameptr:dword
  90. extrn    argv:dword
  91. extrn    argc:word
  92. extrn    errorno:word
  93. extrn    pageproc:word
  94. ;
  95. startpage   dw        1
  96. lastpage    dw        0ffffh
  97. clmcnt        dw        132
  98. lincnt        dw        90
  99. blkcnt        dw        2
  100. gapsize     dw        8
  101. tabcount    dw        8
  102. formfeed    dw        YES
  103. frmtype        dw        PORT
  104. pprtype        dw        STOCK136
  105. formbase    dw        stk136
  106. marginleft  dw      0
  107. marginhead  dw      0
  108. hdrprint    dw        NO
  109. header    label    dword
  110. headeroff   dw        ?
  111. headerseg   dw        ?
  112. pgwidth     dw        272
  113. pghight     dw        90
  114. rawpitch    dw        3
  115. clmpitch    dw        3
  116. hopper        dw        1
  117. pgtype        dw        NO
  118. creturns    dw        NO
  119. filline     dw        ?
  120. linsiz        dw        ?
  121. linumb        dw        NO
  122. numclm        dw        4
  123. numsepchar  db        ' '
  124. even
  125. cset        dw        NO
  126. gset        dw        NO
  127. lset        dw        NO
  128. wset        dw        NO
  129. bset        dw        NO
  130. rset        dw        NO
  131. frmset        dw        NO
  132. mhset        dw        NO
  133. mlset        dw        NO
  134. ;
  135. formlist    label    word
  136.     dw    stk136,stk136
  137.     dw    stka4p,stk80
  138.     dw    a4port,a4land
  139.     dw    b4port,b4land
  140. ;
  141. ;全幅,左マージン,カラム幅,カラム間幅,カラム数,物理行,論理行,上マージン
  142. stk136  pgform  <136,0,136,0,1  ,66,60,0>
  143.         pgform  <204,0,100,4,2  ,82,75,0>
  144.         pgform  <272,0,132,8,2  ,99,90,0>
  145. ;
  146. stk80   pgform  <80,0,80,0,1    ,66,60,0>
  147.         pgform  <120,0,120,0,1  ,82,75,0>
  148.         pgform  <160,0,78,4,2   ,99,90,0>
  149. ;
  150. stka4p  pgform  <78,7,71,0,1    ,64,64,0>
  151.         pgform  <117,10,107,0,1 ,79,79,0>
  152.         pgform  <157,14,143,0,1 ,94,94,0>
  153. ;
  154. a4port  pgform  <78,7,71,0,1    ,67,67,0>
  155.         pgform  <117,10,107,0,1 ,83,83,0>
  156.         pgform  <157,14,143,0,1 ,100,100,0>
  157. ;
  158. a4land  pgform  <113,0,113,0,1  ,46,46,3>
  159.         pgform  <169,0,82,5,2   ,58,58,4>
  160.         pgform  <226,0,110,6,2  ,69,69,4>
  161. ;
  162. b4port  pgform  <97,7,90,0,1    ,82,82,0>
  163.         pgform  <146,10,136,0,1 ,103,103,0>
  164.         pgform  <194,14,88,4,2  ,123,123,0>
  165. ;
  166. b4land  pgform  <136,0,136,0,1  ,57,57,3>
  167.         pgform  <204,0,100,4,2  ,72,72,4>
  168.         pgform  <272,0,132,8,2  ,85,85,5>
  169. ;
  170. srch        findf   <>
  171. ;
  172. clmerror    db    '各種 桁数指定の値が許容範囲外です',CR,LF
  173. clmerrsz    equ    $-clmerror
  174. ;
  175. stdfrm    label    byte
  176. db 'ドットPRT  桁ピッチ 用紙幅 左マージン カラム幅 カラム間幅 カラム数 行ピッチ 物理行 印刷行 上マージン',CR,LF
  177. hlplnbs    label    byte
  178. dotform    label    byte
  179. db 'W 136桁  '
  180. selclm    equ    $-hlplnbs
  181. db '  1   '
  182. stddot db '  136     0     136     0      1   '
  183. selraw    equ    $-hlplnbs
  184. db '  1     66     60      0',CR,LF
  185. hlplnsz    equ    $-hlplnbs
  186. db '           2     204     0     100     4      2     2     82     75      0',CR,LF
  187. db '           3     272     0     132     8      2     3     99     90      0',CR,LF
  188. db 'SL 80桁    1      80     0      80     0      1     1     66     60      0',CR,LF
  189. db '           2     120     0     120     0      1     2     82     75      0',CR,LF
  190. db '           3     160     0      78     4      2     3     99     90      0',CR,LF
  191. db 'SP A4縦    1      78     7      71     0      1     1     64     64      0',CR,LF
  192. db '           2     117    10     107     0      1     2     79     79      0',CR,LF
  193. db '           3     157    14     143     0      1     3     94     94      0',CR,LF
  194. db 'ページPRT 桁ピッチ 用紙幅 左マージン カラム幅 カラム間幅 カラム数 行ピッチ 物理行 印刷行 上マージン',CR,LF
  195. pageform    label    byte
  196. db 'AP A4縦    1   '
  197. stdpag    db '   78     7      71     0      1     1     67     67      0',CR,LF
  198. db '           2     117    10     107     0      1     2     83     83      0',CR,LF
  199. db '           3     157    14     143     0      1     3    100    100      0',CR,LF
  200. db 'AL A4横    1     113     0     113     0      1     1     46     46      3',CR,LF
  201. db '           2     169     0      82     5      2     2     57     57      4',CR,LF
  202. db '           3     226     0     110     6      2     3     69     69      4',CR,LF
  203. db 'BP B4縦    1      97     7      90     0      1     1     82     82      0',CR,LF
  204. db '           2     146    10     136     0      1     2    103    103      0',CR,LF
  205. db '           3     194    14      88     4      2     3    123    123      0',CR,LF
  206. db 'BL B4横    1     136     0     136     0      1     1     57     57      3',CR,LF
  207. db '           2     204     0     100     4      2     2     72     72      4',CR,LF
  208. db '           3     272     0     132     8      2     3     85     85      5',CR
  209. stdfrmsz    equ     $-stdfrm
  210. ;
  211. data    ends
  212. ;
  213. code    segment para    public    'CODE'
  214.     assume    cs:code,ds:data
  215. ;
  216. options     proc
  217. ;
  218.     les    bx,namebuf
  219.     mov    srch.bufoff,bx
  220.     mov    srch.bufseg,es
  221.     mov    srch.bufsiz,4096
  222.     mov    ah,2fh
  223.     int    21h
  224.     lea    bx,[bx+1eh]
  225.     mov    srch.dtaoff,bx
  226.     mov    srch.dtaseg,es
  227. ;
  228.     mov    bx,offset argv
  229. evaloop:
  230.     les    di,[bx]
  231.     mov    al,es:[di]
  232.     inc    di
  233.     cmp    al,'+'
  234.     je    plusoption
  235.     cmp    al,'-'
  236.     jne    srchfilelist
  237.     call    evaloption
  238.     jmp    short    nextloop
  239. plusoption:
  240.     call    asctoint
  241.     jz    nostart
  242.     mov    startpage,ax
  243. nostart:
  244.     cmp    byte ptr es:[di],'-'
  245.     jne    relativepage
  246.     inc    di
  247.     call    asctoint
  248.     jz    nextloop
  249.     cmp    ax,startpage
  250.     jb    nextloop
  251.     mov    lastpage,ax
  252.     jmp    short nextloop
  253. relativepage:
  254.     cmp    byte ptr es:[di],','
  255.     jne    nextloop
  256.     inc    di
  257.     call    asctoint
  258.     jz    nextloop
  259.     dec    ax
  260.     add    ax,startpage
  261.     jc    nextloop
  262.     mov    lastpage,ax
  263.     jmp    short nextloop
  264. srchfilelist:
  265.     dec    di
  266.     mov    srch.namoff,di
  267.     mov    srch.namseg,es
  268.     push    bx
  269.     mov    bx,offset srch
  270.     call    filelist
  271.     pop    bx
  272. nextloop:
  273.     lea    bx,[bx+4]
  274.     dec    argc
  275.     jnz    evaloop
  276. ;
  277.     call    defadjst
  278. ;
  279.     push    ds
  280.     les    di,namebuf
  281.     mov    cx,srch.bufoff
  282.     lds    si,nameptr
  283.     xor    al,al
  284. ptrsetloop:
  285.     jcxz    namend
  286.     cmp    si,1024
  287.     jae    namend
  288.     mov    ds:[si],di
  289.     mov    ds:[si+2],es
  290.     lea    si,[si+4]
  291.   repne scasb
  292.     jmp    short    ptrsetloop
  293. namend:
  294.     pop    ds
  295.     shr    si,1
  296.     shr    si,1
  297.     mov    ax,si
  298.     test    ax,ax
  299.     ret
  300. ;
  301. options     endp
  302. ;
  303. evaloption  proc
  304. ;
  305.     mov    al,es:[di]
  306.     inc    di
  307.     cmp    al,'a'
  308.     jb    optchar
  309.     cmp    al,'z'
  310.     ja    optchar
  311.     sub    al,20h
  312. optchar:
  313.     cmp    al,'?'
  314.     jne    optunit
  315.     jmp    formdisp
  316. optunit:
  317.     cmp    al,'U'
  318.     jne    optcls
  319.     call    asctoint
  320.     jz    binend
  321.     cmp    ax,3
  322.     ja    binend
  323.     mov    hopper,ax
  324. binend:    ret
  325. optcls:
  326.     cmp    al,'C'
  327.     jne    optgap
  328.     mov    formfeed,NO
  329.     ret
  330. optgap:
  331.     cmp    al,'G'
  332.     jne    opthdr
  333.     call    asctoint
  334.     cmp    ax,256
  335.     jae    gapend
  336.     mov    gapsize,ax
  337.     mov    gset,YES
  338. gapend:    ret
  339. opthdr:
  340.     cmp    al,'H'
  341.     jne    optclmsiz
  342.     mov    headeroff,di
  343.     mov    headerseg,es
  344.     mov    hdrprint,YES
  345.     ret
  346. optclmsiz:
  347.     cmp    al,'K'
  348.     jne    optlincnt
  349.     call    asctoint
  350.     jz    clmend
  351.     cmp    ax,512
  352.     ja    clmend
  353.     mov    clmcnt,ax
  354.     mov    cset,YES
  355. clmend:    ret
  356. optlincnt:
  357.     cmp    al,'L'
  358.     jne    optlinumb
  359.     call    asctoint
  360.     jz    linend
  361.     cmp    ax,256
  362.     ja    linend
  363.     mov    lincnt,ax
  364.     mov    lset,YES
  365. linend:    ret
  366. optlinumb:
  367.     cmp    al,'N'
  368.     jne    optpage
  369.     mov    linumb,YES
  370.     call    asctoint
  371.     jz    numdflt
  372.     cmp    ax,10
  373.     ja    numdflt
  374.     mov    numclm,ax
  375.     ret
  376.     mov    numclm,4
  377. numdflt:ret
  378. optpage:
  379.     cmp    al,'P'
  380.     jne    optrtn
  381.     mov    al,es:[di]
  382.     cmp    al,'a'
  383.     jb    pguppr
  384.     sub    al,20h
  385. pguppr:    cmp    al,'A'
  386.     jne    pgtypeb
  387.     mov    pgtype,ASM
  388.     mov    pageproc,offset asmpage
  389.     ret
  390. pgtypeb:cmp    al,'B'
  391.     jne    pgtypec
  392.     mov    pgtype,BASIC
  393.     mov    pageproc,offset baspage
  394.     ret
  395. pgtypec:cmp    al,'C'
  396.     jne    pgtypex
  397.     mov    pgtype,C
  398.     mov    pageproc,offset cpage
  399.     ret
  400. pgtypex:mov    pgtype,EXT
  401.     ret
  402. optrtn:
  403.     cmp    al,'R'
  404.     jne    optpgform
  405.     mov    creturns,YES
  406.     call    asctoint
  407.     jz    rtnend
  408.     cmp    ax,384
  409.     ja    rtnend
  410.     mov    pghight,ax
  411.     mov    rset,YES
  412. rtnend:    ret
  413. optpgform:
  414.     cmp    al,'F'
  415.     jne    optwidth
  416.     mov    frmset,NO
  417.     call    checkform
  418.     cmp    frmset,YES
  419.     je    formend
  420.     call    asctoint
  421.     jz    formraw
  422.     cmp    ax,3
  423.     ja    formraw
  424.     mov    clmpitch,ax
  425. formraw:cmp    byte ptr es:[di],','
  426.     jne    formend
  427.     inc    di
  428.     call    checkform
  429.     cmp    frmset,YES
  430.     je    formend
  431.     call    asctoint
  432.     jz    formpag
  433.     cmp    ax,3
  434.     ja    formpag
  435.     mov    rawpitch,ax
  436. formpag:cmp    byte ptr es:[di],','
  437.     jne    formend
  438.     inc    di
  439.     call    checkform
  440. formend:ret
  441. optwidth:
  442.     cmp    al,'W'
  443.     jne    opttabcnt
  444.     call    asctoint
  445.     jz    wdhend
  446.     cmp    ax,512
  447.     ja    wdhend
  448.     mov    pgwidth,ax
  449.     mov    wset,YES
  450. wdhend:    ret
  451. opttabcnt:
  452.     cmp    al,'T'
  453.     jne    optmargin
  454.     call    asctoint
  455.     jz    tabcend
  456.     cmp    ax,128
  457.     ja    tabcend
  458.     mov    tabcount,ax
  459. tabcend:ret
  460. optmargin:
  461.     cmp    al,'M'
  462.     jne    optmclm
  463.     cmp    byte ptr es:[di],','
  464.     je    mrgnhdr2
  465.     call    asctoint
  466.     cmp    ax,256
  467.     ja    mrgnhdr
  468.     mov    marginleft,ax
  469.     mov    mlset,YES
  470. mrgnhdr:cmp    byte ptr es:[di],','
  471.     jne    mrgnend
  472. mrgnhdr2:inc    di
  473.     call    asctoint
  474.     cmp    ax,256
  475.     ja    mrgnend
  476.     mov    marginhead,ax
  477.     mov    mhset,YES
  478. mrgnend:ret
  479. optmclm:
  480.     cmp    al,'0'
  481.     jb    others
  482.     cmp    al,'9'
  483.     ja    others
  484.     dec    di
  485.     call    asctoint
  486.     jz    others
  487.     cmp    ax,512
  488.     ja    others
  489.     mov    blkcnt,ax
  490.     mov    bset,YES
  491.     cmp    gset,YES
  492.     je    others
  493.     mov    gapsize,2
  494.     mov    gset,YES
  495. others:    ret
  496. ;
  497. evaloption  endp
  498. ;
  499. checkform    proc
  500. ;
  501.     mov    al,es:[di]
  502.     cmp    al,'a'
  503.     jb    cfuppr
  504.     sub    al,20h
  505. cfuppr:    cmp    al,'A'
  506.     jne    fmtypeb
  507.     mov    pprtype,A4
  508.     mov    frmtype,PORT
  509.     mov    frmset,YES
  510.     inc    di
  511.     jmp    checkform
  512. fmtypeb:cmp    al,'B'
  513.     jne    fmtypep
  514.     mov    pprtype,B4
  515.     mov    frmtype,LAND
  516.     mov    frmset,YES
  517.     inc    di
  518.     jmp    checkform
  519. fmtypep:cmp    al,'P'
  520.     jne    fmtypel
  521.     mov    frmtype,PORT
  522.     mov    frmset,YES
  523.     inc    di
  524.     ret
  525. fmtypel:cmp    al,'L'
  526.     jne    fmtypes
  527.     mov    frmtype,LAND
  528.     mov    frmset,YES
  529.     inc    di
  530.     ret
  531. fmtypes:cmp    al,'S'
  532.     jne    fmtypew
  533.     mov    pprtype,STOCK80
  534.     mov    frmtype,LAND
  535.     mov    frmset,YES
  536.     inc    di
  537.     jmp    checkform
  538. fmtypew:cmp    al,'W'
  539.     jne    fmtypee
  540.     mov    pprtype,STOCK136
  541.     mov    frmtype,LAND
  542.     mov    frmset,YES
  543.     inc    di
  544. fmtypee:ret
  545. ;
  546. checkform    endp
  547. ;
  548. defadjst    proc
  549. ;
  550.     cmp    clmpitch,3
  551.     je    pagecheck
  552.     cmp    rawpitch,3
  553.     jne    pagecheck
  554.     mov    ax,clmpitch
  555.     mov    rawpitch,ax
  556. pagecheck:
  557.     mov    bx,pprtype
  558.     shl    bx,1
  559.     add    bx,frmtype
  560.     shl    bx,1
  561.     mov    bx,[bx+offset formlist]
  562.     mov    formbase,bx
  563. ;
  564.     mov    ax,size    pgform
  565.     mov    cx,rawpitch
  566.     dec    cx
  567.     mul    cx
  568.     add    bx,ax
  569. ;
  570.     cmp    rset,YES
  571.     je    rseted
  572.     mov    ax,[bx].physline
  573.     mov    pghight,ax
  574. rseted:
  575.     cmp    lset,YES
  576.     je    lseted
  577.     mov    ax,[bx].prntline
  578.     mov    lincnt,ax
  579. lseted:
  580.     cmp    mhset,YES
  581.     je    mhseted
  582.     mov    ax,[bx].headmrgn
  583.     mov    marginhead,ax
  584. mhseted:
  585.     mov    bx,formbase
  586.     mov    ax,size pgform
  587.     mov    cx,clmpitch
  588.     dec    cx
  589.     mul    cx
  590.     add    bx,ax
  591. ;
  592.     cmp    wset,YES
  593.     je    wseted
  594.     mov    ax,[bx].allwidth
  595.     mov    pgwidth,ax
  596. wseted:
  597.     cmp    cset,YES
  598.     je    cseted
  599.     mov    ax,[bx].blckclmn
  600.     mov    clmcnt,ax
  601. cseted:
  602.     cmp    gset,YES
  603.     je    gseted
  604.     mov    ax,[bx].gapclmn
  605.     mov    gapsize,ax
  606. gseted:
  607.     cmp    bset,YES
  608.     je    bseted
  609.     mov    ax,[bx].blckcount
  610.     mov    blkcnt,ax
  611. bseted:
  612.     cmp    mlset,YES
  613.     je    mlseted
  614.     mov    ax,[bx].leftmrgn
  615.     mov    marginleft,ax
  616. mlseted:
  617. ;
  618.     cmp    rset,YES
  619.     jne    realine
  620.     mov    ax,pghight
  621.     cmp    ax,lincnt
  622.     jae    linerange
  623.     mov    lincnt,ax
  624.     jmp    linerange
  625. realine:
  626.     cmp    lset,YES
  627.     jne    linerange
  628.     mov    ax,lincnt
  629.     cmp    ax,pghight
  630.     jbe    linerange
  631.     mov    pghight,ax
  632. linerange:
  633.     mov    ax,pghight
  634.     sub    ax,lincnt
  635.     mov    filline,ax
  636. ;
  637.     mov    ax,marginhead
  638.     cmp    hdrprint,YES
  639.     jne    noheadprint
  640.     add    ax,2
  641. noheadprint:
  642.     sub    lincnt,ax
  643.     ja    remainline
  644.     add    lincnt,ax
  645.     mov    marginhead,0
  646.     mov    hdrprint,NO
  647. remainline:
  648. ;
  649.     mov    bx,pgwidth
  650.     mov    cx,blkcnt
  651.     sub    bx,marginleft
  652.     ja    blkchk
  653.     add    bx,marginleft
  654.     mov    marginleft,0
  655.     mov    mhset,NO
  656. blkchk:
  657.     cmp    blkcnt,1
  658.     ja    blkchk2
  659.     mov    gapsize,0
  660.     cmp    bx,clmcnt
  661.     ja    blk1
  662.     mov    clmcnt,bx
  663. blk1:    jmp    adjlnum
  664. blkchk2:
  665.     cmp    bx,cx
  666.     jae    clmnchk
  667.     jmp    clmseterrors
  668. clmnchk:
  669.     mov    ax,clmcnt
  670.     mul    cx
  671.     test    dx,dx
  672.     jnz    calclm
  673.     cmp    bx,ax
  674.     jae    gapchk
  675. calclm:
  676.     mov    ax,bx
  677.     cwd
  678.     div    cx
  679.     mov    clmcnt,ax
  680.     mov    cset,NO
  681. gapchk:
  682.     dec    cx
  683.     mov    ax,gapsize
  684.     mul    cx
  685.     test    dx,dx
  686.     jnz    setgap
  687.     cmp    bx,ax
  688.     ja    chkend
  689. setgap:
  690.     mov    gapsize,2
  691.     mov    gset,NO
  692. chkend:
  693.     mov    ax,wset
  694.     add    ax,mlset
  695.     add    ax,cset
  696.     add    ax,gset
  697.     add    ax,bset
  698.     jnz    adjclm
  699.     jmp    adjlnum
  700. adjclm:
  701.     mov    bx,pgwidth
  702.     sub    bx,marginleft
  703.     mov    cx,bx
  704.     cmp    gset,YES
  705.     je    dominagap
  706.     mov    ax,clmcnt
  707.     mul    blkcnt
  708.     test    dx,dx
  709.     jnz    adjdefault
  710.     sub    cx,ax
  711.     jae    remaingap
  712. adjdefault:
  713.     mov    ax,bx
  714.     mov    cx,blkcnt
  715.     dec    cx
  716.     shl    cx,1
  717.     sub    ax,cx
  718.     jbe    clmseterrors
  719.     cwd
  720.     div    blkcnt
  721.     test    ax,ax
  722.     jz    clmseterrors
  723.     mov    clmcnt,ax
  724.     mov    gapsize,2
  725.     jmp    adjlnum
  726. remaingap:
  727.     mov    ax,cx
  728.     mov    bx,blkcnt
  729.     dec    bx
  730.     cwd
  731.     div    bx
  732.     cmp    ax,gapsize
  733.     ja    inrangegap
  734.     mov    gapsize,ax
  735. inrangegap:
  736.     jmp    adjlnum
  737. ;
  738. clmseterrors:
  739.     mov    errorno,-1
  740.     mov    dx,offset clmerror
  741.     mov    cx,clmerrsz
  742.     jmp    abort
  743. ;
  744. dominagap:
  745.     mov    ax,blkcnt
  746.     dec    ax
  747.     mul    gapsize
  748.     test    dx,dx
  749.     jnz    adjdefault
  750.     sub    cx,ax
  751.     jbe    adjdefault
  752.     mov    ax,cx
  753.     cwd
  754.     div    blkcnt
  755.     test    ax,ax
  756.     jz    adjdefault
  757.     cmp    cset,YES
  758.     jne    adjustclm
  759.     cmp    ax,clmcnt
  760.     jb    adjdefault
  761.     jmp    short adjlnum
  762. adjustclm:
  763.     mov    clmcnt,ax
  764. adjlnum:
  765.     cmp    linumb,YES
  766.     jne    adjend
  767.     mov    ax,numclm
  768.     inc    ax
  769.     sub    clmcnt,ax
  770.     ja    adjend
  771.     add    clmcnt,ax
  772.     mov    linumb,NO
  773.     mov    numclm,0
  774. adjend:
  775.     mov    bx,blkcnt
  776.     mov    ax,clmcnt
  777.     mul    bx
  778.     xchg    ax,bx
  779.     dec    ax
  780.     mul    gapsize
  781.     add    ax,bx
  782.     add    ax,marginleft
  783.     cmp    ax,pgwidth
  784.     jae    widthovr
  785.     mov    ax,pgwidth
  786. widthovr:
  787.     add    ax,1fh
  788.     and    ax,0fff0h
  789.     mov    linsiz,ax
  790. ;
  791.     ret
  792. ;
  793. defadjst    endp
  794. ;
  795. formdisp    proc
  796. ;
  797.     mov    ax,ds
  798.     mov    es,ax
  799.     cld
  800.     mov    di,offset stddot
  801.     mov    si,offset stk136
  802.     mov    cx,9
  803.     call    frmsetloop
  804. ;
  805.     mov    di,offset stdpag
  806.     mov    si,offset a4port
  807.     mov    cx,12
  808.     call    frmsetloop
  809. ;
  810.     mov    ax,pprtype
  811.     cmp    ax,A4
  812.     jae    pageprtr
  813.     mov    bx,offset dotform
  814.     test    ax,ax
  815.     jz    setdefmrk
  816.     mov    dx,frmtype
  817.     xor    dx,1
  818.     add    ax,dx
  819.     jmp    short setdefmrk
  820. pageprtr:
  821.     mov    bx,offset pageform
  822.     sub    ax,A4
  823.     shl    ax,1
  824.     add    ax,frmtype
  825. setdefmrk:
  826.     mov    dx,(hlplnsz * 3)
  827.     mul    dx
  828.     add    bx,ax
  829.     mov    cx,hlplnsz
  830.     mov    ax,clmpitch
  831.     dec    ax
  832.     mul    cx
  833.     add    ax,selclm
  834.     mov    si,ax
  835.     mov    word ptr [bx+si],07381h
  836.     mov    word ptr [bx+si+4],07481h
  837.     mov    ax,rawpitch
  838.     dec    ax
  839.     mul    cx
  840.     add    ax,selraw
  841.     mov    si,ax
  842.     mov    word ptr [bx+si],07381h
  843.     mov    word ptr [bx+si+4],07481h
  844. ;
  845.     mov    dx,offset stdfrm
  846.     mov    cx,stdfrmsz
  847.     mov    errorno,0
  848.     jmp    abort
  849. ;
  850. formdisp    endp
  851. ;
  852. frmsetloop    proc
  853. ;
  854.     lodsw
  855.     call    inttoascb
  856.     inc    di
  857.     lodsw
  858.     call    inttoascb
  859.     lea    di,[di+3]
  860.     lodsw
  861.     call    inttoascb
  862.     inc    di
  863.     lodsw
  864.     call    inttoascb
  865.     lea    di,[di+2]
  866.     lodsw
  867.     call    inttoascb
  868.     lea    di,[di+9]
  869.     lodsw
  870.     call    inttoascb
  871.     lea    di,[di+2]
  872.     lodsw
  873.     call    inttoascb
  874.     lea    di,[di+2]
  875.     lodsw
  876.     call    inttoascb
  877.     lea    di,[di+18]
  878.     loop    frmsetloop
  879.     ret
  880. ;
  881. frmsetloop    endp
  882. ;
  883. code    ends
  884.     end
  885.